<?php
/**
 * Created by Pako
 * Date: 2018/8/19
 * Time: 18:05
 */

namespace App\Http\Controllers\Admin\Auth;


use App\Http\Controllers\Controller;
use App\Http\Request\Auth\PermissionStore;
use App\Repositories\Auth\PermissionRepository;
use Illuminate\Http\Request;

class PermissionController extends Controller
{
    protected $permission;

    public function __construct(PermissionRepository $permission)
    {
        $this->permission = $permission;
    }


    public function index()
    {
        return $this->permission->index();
    }

    public function lists()
    {
        return $this->permission->list();
    }

    /**
     *
     * 权限详情
     * @author Paco
     * @createTime 2018/8/20 17:48
     * @param $permission_id
     * @return \Illuminate\Database\Eloquent\Model|null|object|static
     */
    public function show($permission_id)
    {
        return $this->permission->show($permission_id);
    }

    /**
     * 添加权限
     *
     * @author Pako
     * @createTime 2018/8/19 18:21
     * @param PermissionStore $permission
     * @param Request $request
     * @return mixed
     * @throws \Illuminate\Validation\ValidationException
     */
    public function store(PermissionStore $permission, Request $request)
    {
        $data = $permission->validated($request);
        return $this->permission->store($data);
    }

    /**
     *
     * 更新权限
     * @author Paco
     * @createTime 2018/8/20 12:13
     * @param PermissionStore $permission
     * @param Request $request
     * @return mixed
     * @throws \Illuminate\Validation\ValidationException
     */
    public function save(PermissionStore $permission, Request $request)
    {
        $data = $permission->validated($request);
        return $this->permission->save($data);
    }

    /**
     *
     * 删除权限
     * @author Paco
     * @createTime 2018/8/20 17:46
     * @param $permission_id
     * @return mixed
     */
    public function del($permission_id)
    {
        return $this->permission->del($permission_id);
    }
}